package com.meetingshow.action.meeting;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.meetingshow.action.MeetingShowAction;
import com.meetingshow.form.MeetingShowForm;
import com.meetingshow.service.meeting.IMeetingSVC;
import com.meetingshow.utils.UIServiceFactory;

public class MeetingOpAction extends MeetingShowAction {
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse res)
			throws Exception {
		
		Logger logger = Logger.getLogger(MeetingOpAction.class);
		logger.info("MeetingMgAction");
		//String forward = "success";
		MeetingShowForm meetingShowForm = (MeetingShowForm)form;
		// 根据不同的操作，调用不同的处理方法
		String method = request.getParameter("method");
		String param = request.getParameter("param");
		
		System.out.println("method is " + method);
		System.out.println("param is " + meetingShowForm.getParam());

		if (method != null && method.length() > 0 && param != null && param.length() > 0) {
			IMeetingSVC meetingSVC = UIServiceFactory.getMeetingSVC();
			if (method.equalsIgnoreCase("setAttention")) {
				int rtn = meetingSVC.setAttention(param);
				res.getWriter().print(rtn);
			}
			if (method.equalsIgnoreCase("getAttentionList")) {
				String rtn = meetingSVC.getAttentionList(param).toString();
				System.out.println("rtn of getAttentionList is " + rtn);
				res.getWriter().print(rtn);
			}
			if (method.equalsIgnoreCase("getTopListByType")) {
				String rtn = meetingSVC.getTopListByType(param).toString();
				res.getWriter().print(rtn);
			}
			if (method.equalsIgnoreCase("searchByTitle")) {
				String rtn = meetingSVC.searchByTitle(param).toString();
				res.getWriter().print(rtn);
			}
			if (method.equalsIgnoreCase("getMeetingListBySort")) {
				String rtn = meetingSVC.getMeetingListBySort(param).toString();
				res.getWriter().print(rtn);
			}
			
		} else {
			System.out.println("Bad param in MeetingOpAction ......");			
		}
		return null;
	}
}
